package com.adaxi.adc.business.passengertrip.controller;

import com.adaxi.adc.business.passengertrip.feign.service.IVehicleTripFeignService;
import com.adaxi.adc.business.passengertrip.pojo.AdcPassengerTrip;
import com.adaxi.adc.business.passengertrip.pojo.AdcRoutePrice;
import com.adaxi.adc.business.passengertrip.service.impl.PassengerTripServiceImpl;
import com.adaxi.adc.common.common.CommonResult;
import com.adaxi.adc.common.utils.UuidUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "乘客发布拼车接口",tags = "乘客发布拼车接口")
@RestController
public class PassengerTripOrderController {
    @Autowired
    RocketMQTemplate rocketMQTemplate;

    @Autowired
    PassengerTripServiceImpl passengerTripService;



    @Autowired
    IVehicleTripFeignService iVehicleTripFeignService;

    @ApiOperation("路线价格查询")
    @GetMapping("/queryAllRoute")
    public CommonResult queryAllRoute(){
        CommonResult<AdcRoutePrice> list= iVehicleTripFeignService.findAllRoutePrices();
            return CommonResult.SUCCESS("行程价格查询成功",list);
    }


    @ApiOperation("乘客发布拼车订单")
    @PostMapping("/passenger/order")
    public CommonResult InsertOrder (@RequestBody AdcPassengerTrip adcPassengerTrip){
        adcPassengerTrip.setId(UuidUtil.get32UUID());
        passengerTripService.save(adcPassengerTrip);
        return CommonResult.SUCCESS("订单提交成功",adcPassengerTrip);
    }

}
